//
//  STTools_NetWrokManger.h
//  GodHorses
//
//  Created by coder on 2017/11/14.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "STTools_Error.h"
typedef NS_ENUM(NSInteger, STHttpRequestType_stoneobs_enum) {
    STHttpRequestType_stoneobs_enumGet,
    STHttpRequestType_stoneobs_enumPost,
    STHttpRequestType_stoneobs_enumDelete,
    STHttpRequestType_stoneobs_enumPut,
};
typedef void (^STNetSuccess_stoneobs_handle)(NSURLSessionDataTask *operation, id responseObject);
typedef void (^STNetFail_stoneobs_handle)(NSString *stateCode, STTools_Error *error,NSError * originError);
typedef void (^STNetProgress_stoneobs_handle)(NSProgress* progress);
typedef void (^STNetFinsh_stoneobs_handle)(NSURLResponse *  response, NSURL *  filePath, NSError *  error);
@interface STTools_NetWrokManger : NSObject
+ (STTools_NetWrokManger *)defaultClient;
+ (void)stoneobs_fun_shownNormalRespMsgWithResponse:(id)response;
/**
 * @brief HTTP请求处理接口
 * @param url 接口地址
 * @param method 请求方式
 * @param parameters 参数
 * @param success 成功回调
 * @param failure 失败回调
 */
- (void)stoneobs_fun_requestWithPath:(NSString *)url
                 method:(STHttpRequestType_stoneobs_enum)method
             parameters:(id)parameters
                success:(STNetSuccess_stoneobs_handle)success
                failure:(STNetFail_stoneobs_handle)failure;

//将会忽略固定成功之值
- (void)stoneobs_fun_requestIgnoreSuccessWithPath:(NSString *)url
                              method:(STHttpRequestType_stoneobs_enum)method
                          parameters:(id)parameters
                             success:(STNetSuccess_stoneobs_handle)success
                             failure:(STNetFail_stoneobs_handle)failure;

/**
 * @brief HTTP请求处理接口,有返回值
 * @param url 接口地址
 * @param method 请求方式
 * @param parameters 参数
 * @param success 成功回调
 * @param failure 失败回调
 */
- (NSURLSessionDataTask *)stoneobs_fun_taskstoneobs_fun_requestWithPath:(NSString *)url
                                       method:(STHttpRequestType_stoneobs_enum)method
                                   parameters:(id)parameters
                                      success:(STNetSuccess_stoneobs_handle)success
                                      failure:(STNetFail_stoneobs_handle)failure;


/**
 默认 post 请求
 @param url HTTP请求处理接口
 @param parameters 参数
 @param image 一张图片
 @param progress 进度
 @param success 成功回调
 @param failure 失败回到
 */
- (void)stoneobs_fun_imagerequestWithPath:(NSString *)url
                  parameters:(id)parameters
                       image:(UIImage*)image
                    progress:(STNetProgress_stoneobs_handle)progress
                     success:(STNetSuccess_stoneobs_handle)success
                     failure:(STNetFail_stoneobs_handle)failure;
//附带imageName 参数
- (void)stoneobs_fun_imagerequestWithPath:(NSString *)url
                  parameters:(id)parameters
                       image:(UIImage*)image
                   imageName:(NSString*)imageName
                    progress:(STNetProgress_stoneobs_handle)progress
                     success:(STNetSuccess_stoneobs_handle)success
                     failure:(STNetFail_stoneobs_handle)failure;

- (void)stoneobs_fun_imagesrequestWithPath:(NSString *)url
                  parameters:(id)parameters
                      images:(NSArray*)imageArray
                    progress:(STNetProgress_stoneobs_handle)progress
                     success:(STNetSuccess_stoneobs_handle)success
                     failure:(STNetFail_stoneobs_handle)failure;
//附带image参数
- (void)stoneobs_fun_imagesrequestWithPath:(NSString *)url
                  parameters:(id)parameters
                      images:(NSArray*)imageArray
                  imageNames:(NSArray*)imageNames
                    progress:(STNetProgress_stoneobs_handle)progress
                     success:(STNetSuccess_stoneobs_handle)success
                     failure:(STNetFail_stoneobs_handle)failure;

- (NSURLSessionDownloadTask *)stoneobs_fun_downLoadWithUrl:(NSString *)url
                                     progress:(STNetProgress_stoneobs_handle)progress
                                      success:(STNetFinsh_stoneobs_handle)CompletionHandler;


/**
 默认 post 请求 上传文件
 @param url HTTP请求处理接口
 @param filePath 文件本地路径
 @param parameters 参数
 @param progress 进度
 @param success 成功回调
 @param failure 失败回到
 */
- (void)stoneobs_fun_uploadFileWithUrl:(NSString *)url
                 filePath:(NSString *)filePath
               parameters:(id)parameters
                 progress:(STNetProgress_stoneobs_handle)progress
                  success:(STNetSuccess_stoneobs_handle)success
                  failure:(STNetFail_stoneobs_handle)failure;

- (NSURLSessionDataTask *)stoneobs_fun_sessionuploadFileWithUrl:(NSString *)url
                                          filePath:(NSString *)filePath
                                        parameters:(id)parameters
                                          progress:(STNetProgress_stoneobs_handle)progress
                                           success:(STNetSuccess_stoneobs_handle)success
                                           failure:(STNetFail_stoneobs_handle)failure;
@end
